package com.example.a90727.ce;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class MainActivity extends AppCompatActivity {

    private String[]list1=new String[]{"220","230","240","150","250"};
    private String[]list2=new String[]{"100","230","110","120","250"};
    private List list3=new ArrayList();
    private  List list4=new ArrayList();
    private  List list5=new ArrayList();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        for (int i = 0; i < list1.length; i++) {
            Log.e("", String.valueOf(Arrays.equals(new String[]{list1[i]}, new String[]{list2[i]})));
        }
        for(int x=0;x<list2.length;x++){

        if (Arrays.binarySearch(new String[]{list1[x]}, list2[x]) < 0){
            list3.add(0);


            }else {
            list3.add(1);
        }

        }
        Log.e("",Arrays.toString(list3.toArray()));

for ( int i=0;i<list2.length;i++) {
    if (list1[i] == list2[i]) {

        list5.add(1);
    } else {
        list5.add(0);
    }


}
        Log.e("list5",Arrays.toString(list5.toArray()));


getIds(list1,list2);


    }




    public void getIds(String[] a, String[] b){

        Set<Integer> same = new HashSet<Integer>();  //用来存放两个数组中相同的元素
       Set<String> temp=new HashSet<String>();  //用来存放数组a中的元素

        for (int i = 0; i < a.length; i++) {
            temp.add(a[i]);   //把数组a中的元素放到Set中，可以去除重复的元素
        }

        for (int j = 0; j < b.length; j++) {
            //把数组b中的元素添加到temp中
            //如果temp中已存在相同的元素，则temp.add（b[j]）返回false
            if(!temp.add(b[j])){
                list4.add(1);
            }else {
                list4.add(0);
            }

        }
        Log.e("list4",Arrays.toString(list4.toArray()));
    }






}
